#ifndef __TRACK_H__
#define __TRACK_H__
#include "../include/Typedef.hpp"
#include "random"
#include "ctime"
#include "../include/MultipleViewGeometry.hpp"
#include "../include/Param.hpp"
#include "../include/Frame.hpp"
#include "../include/Matcher.hpp"
#include "../include/MapPoint.hpp"
#include "../include/Debuger.hpp"
#include "../include/Optimizer.hpp"
#include "../include/LocalMap.hpp"
#include "../include/KeyFrameDatabase.hpp"
using namespace std;
using namespace cv;
namespace ORBSLAM
{
    class KeyFrame;
    class Frame;
    class MapPoint;
    class Track
    {
    public:
        // Mat mm_velocity;

    private:
        /* data */
        int mi_itration_num;
        Param *mp_param;
        MultipleViewGeometry *mp_multipleviewgeometry;

        // KeyFrame *mp_ref_KF;

    public:
        Track();
        ~Track();
        void Set_param(Param *param);
        void Track_frame();
        bool Mono_initial_two_frame(vector<KeyPoint> &v_kps1, vector<KeyPoint> &v_kps2, vector<int> &v_matches12, Mat &R21, Mat &t21, vector<Point3f> &v_p3f, vector<bool> &v_triangulated,vector<int> &v_contribution_pt1,vector<int> &v_contribution_pt2,vector<pair<int,int>> &match_score);
        // void Set_ref_KF(KeyFrame *p_KF);
        bool Track_reference_keyframe(KeyFrame * p_ref_KF,Frame &cur_frame,Matcher * p_matcher);
        bool Track_by_motion_predict(Frame &last_frame,Frame &cur_frame,Matcher * p_matcher,Mat &velocity);
        bool Track_local_map(LocalMap* p_localmap,Frame &cur_frame,Matcher * p_matcher,int &nmatch_inline);
        bool Relocalization(Frame &cur_frame,KeyFrameDatabase* p_keyframe_database,Matcher* p_matcher,Map* p_map);

        void Search_local_match(LocalMap* p_local_map,Frame & cur_frame,Matcher *p_matcher);
    };

}
#endif // __TRACK_H__